package com.ruoyi.web.cp.domain.rm;

import cn.hutool.core.date.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CpAo5 {
    private Integer id;
    private String preDrawIssue;
    private Date preDrawTime;
    private String preDrawCode;
    private String preDrawCode1;
    private String preDrawCode2;
    private String preDrawCode3;
    private String preDrawCode4;
    private String preDrawCode5;

    public CpAo5(String preDrawIssue, String preDrawTime, String preDrawCode) {
        this.preDrawIssue = preDrawIssue;
        this.preDrawTime = DateUtil.parse(preDrawTime, "yyyy-MM-dd HH:mm:ss");
        this.preDrawCode = preDrawCode;
        String[] codes = preDrawCode.split(",");
        this.preDrawCode1 = codes[0];
        this.preDrawCode2 = codes[1];
        this.preDrawCode3 = codes[2];
        this.preDrawCode4 = codes[3];
        this.preDrawCode5 = codes[4];
    }

    public CpAo5(String preDrawIssue, Long preDrawTime, String preDrawCode) {
        this.preDrawIssue = preDrawIssue;
        this.preDrawTime = new Date(preDrawTime);
        this.preDrawCode = preDrawCode;
        String[] codes = preDrawCode.split(",");
        this.preDrawCode1 = codes[0];
        this.preDrawCode2 = codes[1];
        this.preDrawCode3 = codes[2];
        this.preDrawCode4 = codes[3];
        this.preDrawCode5 = codes[4];
    }

    public String getPreDrawCodeByIndex(String index) {
        String code = null;
        switch (index) {
            case "1":
            case "preDrawCode1":
                code = this.preDrawCode1;
                break;
            case "2":
            case "preDrawCode2":
                code = this.preDrawCode2;
                break;
            case "3":
            case "preDrawCode3":
                code = this.preDrawCode3;
                break;
            case "4":
            case "preDrawCode4":
                code = this.preDrawCode4;
                break;
            case "5":
            case "preDrawCode5":
                code = this.preDrawCode5;
                break;
            default:
                break;
        }
        return code;
    }

    public Long getPreDrawIssueToLong() {
        return Long.valueOf(this.preDrawIssue);
    }
}
